package com.kpijavatraining.module;


import java.io.IOException;

import com.kpijavatraining.module.io.LoaderFromFile;
import com.kpijavatraining.module.io.Restore;
import com.kpijavatraining.module.utils.Checker;

public class PrepareQuestions {

private Checker checker;
	
	public PrepareQuestions(){
		checker = new Checker();
	}
	
	/**
	 * method initializes a session 
	 * @return boolean
	 * @throws IOException
	 * @throws ClassNotFoundException
	 * @throws CloneNotSupportedException
	 */
	public Session getSession(User user) throws IOException, ClassNotFoundException, CloneNotSupportedException{
		boolean isUncompleteTest = checker.hasUncompleteTest(user);	
		if(isUncompleteTest){
			return (new Restore().loadQuestions(user));	
		}
		return (new LoaderFromFile().loadQuestions(user));
	}
}
